import {AccountService} from '../../services/account/account.service';
import {Resolver, Query, Args, Mutation} from '@nestjs/graphql';

@Resolver('Account')
export class AccountResolver {
    constructor(
        private readonly accountService: AccountService,
    ) {
    }

    @Query()
    async accountList() {
        return await this.accountService.accountList();
    }

    @Query()
    async account(
        @Args('id') id: number,
    ) {
        return await this.accountService.account(id);
    }


    @Mutation()
    async createAccount(
        @Args('username') username: string,
        @Args('password') password: string,
    ) {
        return await this.accountService.createAccount(username, password);
    }

    @Mutation()
    async modifyAccountById(
        @Args('id') id: number,
        @Args('data') data: { username: string, password: string }
    ) {
        return await this.accountService.modifyAccountById(id, data);
    }

    @Mutation()
    async deleteAccountById(
        @Args('id') id: number
    ) {
        return await this.accountService.deleteAccountById(id);
    }

}
